package com.maiji.cloud.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.context.annotation.Bean;

public class RibbonShopingMallConfig {

    @Bean  // 自定义负载策略
    public IRule myRule()	{
        return new RoundRobinRule();  // 轮询负载
    }

    /**
     * 自定义服务列表
    String listOfServers = "http://localhost:8031";

    @Bean
    public ServerList<Server> ribbonServerList() {
        List<Server> list = Lists.newArrayList();
        if (!Strings.isNullOrEmpty(listOfServers)) {
            for (String s: listOfServers.split(",")) {
                list.add(new Server(s.trim()));
            }
        }
        Server[] serverList = new Server[list.size()];
        list.toArray(serverList);
        return new StaticServerList<Server>(serverList);
    }*/

}
